package com.qk.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qk.common.PageResult;
import com.qk.entity.OperateLog;
import com.qk.mapper.OperateLogMapper;
import com.qk.service.OperateLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 操作日志管理Service实现类
 */
@Service
public class OperateLogServiceImpl extends ServiceImpl<OperateLogMapper, OperateLog> implements OperateLogService {

    @Autowired
    private OperateLogMapper operateLogMapper;

    @Override
    public PageResult<OperateLog> getLogsByCondition(String operateUserName, Integer page, Integer pageSize) {
        // 使用 MyBatis-Plus 的 Page 对象进行分页查询
        Page<OperateLog> p = new Page<>(page, pageSize);
        List<OperateLog> logs = operateLogMapper.getLogsByCondition(p, operateUserName);
        // 封装分页结果
        return new PageResult<>(p.getTotal(), logs);
    }
}